package org.example.repository;

import org.example.repository.condition.BinaryOperatorCondition;
import org.example.repository.condition.ConjectionCondition;
import org.example.repository.condition.ExpressionCondition;
import org.example.repository.condition.UnaryConjectionCondition;

public abstract class Condition {

    public static final String OP_GTE = ">=";
    public static final String OP_EQUAL = "=";
    public static final String OP_GT = ">";
    public static final String OP_LT = "<";
    public static final String OP_LTE = "<=";
    public static final String OP_IN = "in";
    public static final String LOGICAL_OR = "or";
    public static final String LOGICAL_AND = "and";
    public static final String LOGICAL_NOT = "not";

    public static Condition equals(String property, Object value) {
        return new BinaryOperatorCondition(OP_EQUAL, property, value);
    }

    public static Condition gt(String property, Object value) {
        return new BinaryOperatorCondition(OP_GT, property, value);
    }

    public static Condition gte(String property, Object value) {
        return new BinaryOperatorCondition(OP_GTE, property, value);
    }

    public static Condition lt(String property, Object value) {
        return new BinaryOperatorCondition(OP_LT, property, value);
    }

    public static Condition lte(String property, Object value) {
        return new BinaryOperatorCondition(OP_LTE, property, value);
    }

    public static Condition in(String property, Object[] values) {
        return new BinaryOperatorCondition(OP_IN, property, values);
    }

    public static Condition exp(String expression) {
        return new ExpressionCondition(expression);
    }

    public static Condition or(Condition... conditions) {
        return new ConjectionCondition(LOGICAL_OR, conditions);
    }

    public static Condition and(Condition... conditions) {
        return new ConjectionCondition(LOGICAL_AND, conditions);
    }

    public static Condition not(Condition condition) {
        return new UnaryConjectionCondition(LOGICAL_NOT, condition);
    }
}
